
import UIKit
import Moya

enum MYGScheduleAPI {
    case addSchedule(params: [String: Any])
    case scheduleList(params: [String: Any])
    case calendarList(params: [String: Any])
    case addPatient(params: [String: Any])
    case meetingsSchedule(params: [String: Any])
    case joinMeetings(params: [String: Any])
    case changeScheduleStatue(param:String)
    case editSchedule(param:[String: Any])
    case showMeetingInfo(param:[String: Any])
    case deleteSche(param:String)

}

extension MYGScheduleAPI: MYGTargetType {
    var params: [String : Any] {
        switch self {
        case let .addSchedule(params):
            return params
        case let .scheduleList(params):
            return params
        case let .calendarList(params):
            return params
        case let .addPatient(params):
            return params
        case let .meetingsSchedule(params):
            return params
        case let .joinMeetings(params):
            return params
        case let .showMeetingInfo(params):
            return params
        case let .changeScheduleStatue(params):
            return ["schedule_status":3]
        case let .editSchedule(params):
            return params
        case let .deleteSche(params):
            return [:]
        }
      
    }
    
    var path: String {
        switch self {
        case .addSchedule:
            "/api/schedule/schedule"
        case .scheduleList:
            "/api/schedule/schedule"
        case .calendarList:
            "/api/schedule/get_month_schedule"
        case .addPatient:
            "/api/patient/add_patient"
        case .meetingsSchedule:
            "/api/schedule/get_meeting_schedule"
        case .joinMeetings:
            "/api/schedule/set_meeting_schedule"
        case .changeScheduleStatue(let para):
            "/api/schedule/schedule/\(para)"
        case .editSchedule(let para):
            "/api/schedule/schedule/\(para["id"] ?? "")"
        case .showMeetingInfo:
            "/api/schedule/showMeetingInfo"
        case .deleteSche(let para):
            "/api/schedule/schedule/\(para)"
        }
    }
    
    var method: Moya.Method {
        switch self {
        case .addSchedule,.meetingsSchedule:
            .post
        case .scheduleList,.calendarList,.joinMeetings,.addPatient,.showMeetingInfo:
            .get
        case .changeScheduleStatue,.editSchedule:
                .put
        case .deleteSche:
                .delete
        }
    }
    
    var baseURL: URL {
        switch self {
        case .addSchedule,.calendarList,.addPatient,.scheduleList,.meetingsSchedule,.joinMeetings,.changeScheduleStatue,.editSchedule,.showMeetingInfo,.deleteSche:
            return  URL(string: BaseUrl)!
//        case
//                .scheduleList:
//            return  URL(string: "http://47.93.150.30:8083")!
        }
    }
}
